<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body { background-color: #f8f9fa; }
        .change-password-container {
            max-width: 400px;
            margin: 60px auto;
            padding: 30px;
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0,0,0,0.08);
        }
        .bank-title { text-align: center; color: #0d6efd; margin-bottom: 30px; }
        .error-message { color: #dc3545; margin-top: 10px; text-align: center; }
    </style>
</head>
<body>
<div class="container mt-5" style="max-width:400px;">
    <h2 class="mb-4">修改密码</h2>
    <form th:action="@{/user/change-password}" method="post">
        <div class="mb-3">
            <label class="form-label">卡号</label>
            <input type="text" class="form-control" name="cardID" required />
        </div>
        <div class="mb-3">
            <label class="form-label">原密码</label>
            <input type="password" class="form-control" name="oldPassword" required />
        </div>
        <div class="mb-3">
            <label class="form-label">新密码</label>
            <input type="password" class="form-control" name="newPassword" required />
        </div>
        <div class="d-grid gap-2">
            <button type="submit" class="btn btn-primary">确认修改</button>
            <a href="/user/main" class="btn btn-link">返回主页</a>
        </div>
        <div th:if="${error}" class="text-danger mt-2" th:text="${error}"></div>
        <div th:if="${success}" class="text-success mt-2" th:text="${success}"></div>
    </form>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
<script>
    document.querySelector('form').addEventListener('submit', function(e) {
        const newPassword = document.getElementById('newPassword').value;
        const confirmPassword = document.getElementById('confirmPassword').value;
        if (newPassword !== confirmPassword) {
            e.preventDefault();
            alert('两次输入的新密码不一致！');
        }
        if (newPassword.length !== 6) {
            e.preventDefault();
            alert('新密码必须是6位！');
        }
    });
</script>
</body>
</html> 